package com.duoec.doc.mock.dto;

/**
 *
 * @author xuwenzhen
 * @date 2020/2/5
 */
public class DuoMockResponse {
    public static final int SUCCESS_CODE = 200;

    /**
     * 响应状态码：200=正常 404=记录找不到 403=权限不足 500=参数有误 503=未知错误
     * @demo 200
     */
    private Integer code;

    /**
     * 错误信息
     * @demo 调用duo-doc mock接口失败
     */
    private String msg;

    /**
     * 响应体
     * @demo {"name": "hello duo-doc mock!"}
     */
    private String body;

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getBody() {
        return body;
    }

    public void setBody(String body) {
        this.body = body;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public static DuoMockResponse error(String message) {
        DuoMockResponse response = new DuoMockResponse();
        response.setCode(503);
        response.setMsg(message);
        return response;
    }

    public static DuoMockResponse success() {
        DuoMockResponse response = new DuoMockResponse();
        response.setCode(200);
        return response;
    }

    public static DuoMockResponse success(String body) {
        DuoMockResponse response = new DuoMockResponse();
        response.setCode(200);
        response.setBody(body);
        return response;
    }
}
